﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;//Add Ref

namespace Day2
{
    public partial class CallPage : PhoneApplicationPage
    {
        public CallPage()
        {
            InitializeComponent();
			bntShowCall.Click +=new System.Windows.RoutedEventHandler(bntShowCall_Click);
        	bntCallMom.Click +=new System.Windows.RoutedEventHandler(bntCallMom_Click);
			bntCallPolice.Click +=new System.Windows.RoutedEventHandler(bntCallPolice_Click);
		}

        private void bntBrowseNumber_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	// TODO: Add event handler implementation here.
			PhoneNumberChooserTask p = new PhoneNumberChooserTask();
			p.Completed +=new System.EventHandler<Microsoft.Phone.Tasks.PhoneNumberResult>(p_Completed);
			p.Show();
        }

        private void p_Completed(object sender, Microsoft.Phone.Tasks.PhoneNumberResult e)
        {
        	// TODO: Add event handler implementation here.
			if(e.TaskResult == TaskResult.OK){
				txtNumber.Text=e.PhoneNumber;
				//e.DisplayName
			}
        }

        private void bntShowCall_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	// TODO: Add event handler implementation here.
			PhoneCallTask call = new PhoneCallTask();
			call.DisplayName = "Call Some One!";
			call.PhoneNumber = txtNumber.Text;
			call.Show();
        }

        private void bntCallMom_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	// TODO: Add event handler implementation here.
			PhoneCallTask call = new PhoneCallTask();
			call.DisplayName = "Call Mom!";
			call.PhoneNumber = "12304444";
			call.Show();
        }

        private void bntCallPolice_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	// TODO: Add event handler implementation here.
			PhoneCallTask call = new PhoneCallTask();
			call.DisplayName = "Call Police";
			call.PhoneNumber = "191";
			call.Show();
        }
    }
}
